if ($('.side-navigation').length) {
    var closeBtn = $('.close');
    var sideAffix = $('.side-navigation-affix');
    var sideBtn = $('a.navigation-btn');
    var sideNav = $('.side-navigation-large');
    var sideSection = $('.navigation-section');
    var sideTopSpacing = 48;

    if ($('.side-navigation-small').length) {
        sideNav = $('.side-navigation-small');
    }

    var topOffset = sideSection.offset().top - sideTopSpacing;
    var bottomOffset = $('body').height() - sideSection.offset().top - sideSection.height();

    sideAffix.affix({
        offset: {
            top: topOffset,
            bottom: bottomOffset
        }
    });

    sideAffix.width(sideNav.parent().width());

    sideBtn.on('click', function(){
        sideNav.css("display", "block");
        sideSection.css("display", "none");
        sideBtn.css("display", "none");
        $('body').css("overflow", "hidden");
    });
    closeBtn.on('click', function(){
        sideNav.css("display", "");
        sideSection.css("display", "");
        sideBtn.css("display", "inline-block");
        $('body').css("overflow", "");
    });
}